package local.blueheart.data.springdatademo.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.DependsOn;
import org.springframework.web.servlet.ViewResolver;
import org.springframework.web.servlet.config.annotation.*;
import org.springframework.web.servlet.view.InternalResourceViewResolver;
import org.springframework.web.servlet.view.JstlView;
import org.springframework.web.servlet.view.UrlBasedViewResolver;

@Configuration
public class WebMvcConfigAdapter implements WebMvcConfigurer {


    public void addViewControllers(ViewControllerRegistry registry) {
        registry.addViewController("/login").setViewName("/login");
    }

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/detail/**").addResourceLocations("file:///Users/liuzhenxing/temp/dominotransfer/lib/fsarchive/fsarchivestore_B5T9QH/nsf/");
    }
      @Bean(name = "internalResolver")
    public ViewResolver internalViewResolver() {
        InternalResourceViewResolver resolver = new InternalResourceViewResolver();
        resolver.setPrefix("");
        resolver.setSuffix(".mhtml");
        return resolver;
    }


//    @Override
//    public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {
//        configurer.enable();
//    }
//
//    @Override
//    public void configureViewResolvers(ViewResolverRegistry registry) {
//        UrlBasedViewResolver resolver = new UrlBasedViewResolver();
//        resolver.setPrefix(""); // NOTE: no preffix here
//        resolver.setViewClass(JstlView.class);
//        resolver.setSuffix(".mht"); // NOTE: no suffix here
//        registry.viewResolver(resolver);
//    }

//    @Bean(name = "jstlViewResolver")
//    public ViewResolver jstlViewResolver() {
//        UrlBasedViewResolver resolver = new UrlBasedViewResolver();
//        resolver.setPrefix(""); // NOTE: no preffix here
//        resolver.setViewClass(JstlView.class);
//        resolver.setSuffix(".mht"); // NOTE: no suffix here
//        return resolver;
//    }


}
